// forward declare
class TiXmlElement;

class GameLevelMgr
{
public:
	//=== vars ===//
	VxIrrBase *							m_poIrrBase;			// irrlich base implementationm
	irr::video::IVideoDriver*			m_poDriver;				// irrlicht video driver
	irr::scene::ISceneManager*			m_poSceneMgr;			// irrlicht scene manager

	F32									m_f32GameVersion;			// version of game
	F32									m_f32LevelVersion;		// version of level format
	irr::core::stringc					m_strLevelFile;			// file containing level data
	irr::core::array<EntTemplate *>		m_apoEntTemplates;		// array of entity templates ptrs
	irr::core::array<EntSpawnData *>	m_apoEntSpawnData;		// array of entity spawn data ptrs

	irr::core::array<irr::core::stringc> m_astrScripts;			// list of scripts
	irr::core::stringc					m_astrSkybox[ eMaxCubeSide ];			// list textures for skybox
	irr::video::ITexture *				m_apoSkyboxTex[ eMaxCubeSide ];

	// entities
	//irr::core::array<EntBase *>			m_apoEnts;			// list of entities created

	irr::scene::ISceneNode *			m_poSkyBoxNode;		// skybox if any
	


	//=== constructor ===//
	GameLevelMgr();
	//=== destructor ===//
	~GameLevelMgr();

	//=== properties ===//
	F32							GetGameVersion()	{ return m_f32GameVersion; }
	F32							GetLevelVersion()	{ return m_f32LevelVersion; }
	const irr::core::stringc&	GetLevelFile()		{ return m_strLevelFile; }

	//=== methods ===//
	//! load and initialize level
	RCODE			GameLevelStartup( VxIrrBase * poIrrBase, const char * pLevelFileName, BOOL bReloadFromResume = false );
	//! destroy level
	RCODE			GameLevelShutdown( void );
	//! reset variables from any previous load of a level
	virtual void	ResetVars( void );

	//! get entity template by name
	EntTemplate *	GetEntTemplate( const char * pTemplateName );
	//! get entity template by id
	EntTemplate *	GetEntTemplateById( S32 s32TemplateId );

	//! xml template property reader
	RCODE 			GetEntTemplateProperties( TiXmlElement * poTemplateElement, EntTemplate& oEntTemplate);
	//! xml spawn property reader
	RCODE 			GetEntSpawnProperties( TiXmlElement * poSpawnElement, EntSpawnData& oEntSpawnData);
	//! create an entity from a spawn date
	EntBase *		CreateEntitiy( const EntSpawnData& oEntSpawnData );
	//! Creates a constraint from constraint data
	EntBase *		CreateConstraint( const EntConstraintData& oEntConstraintData );


	//! spawn all of the entities in the level
	void			SpawnAllEntities( void );
	//! run scripts
	void			RunScripts( void );

	//! unload level resources
	void			UnloadLevelResources( void );


};

extern GameLevelMgr g_GameLevelMgrImp;
